﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using System.Data.SqlClient;

namespace DataLayer
{
    public static class DatCompra
    {
        public static decimal InsertCompra(dsBoleto.CompraRow rCompra)
        {
            Util.DBParameter Monto;
            Util.DBParameter IdBeneficiario;
            Util.DBParameter IdPostnet;
            Util.DBParameter IdTarjeta;
        
            List<Common.Util.DBParameter> parameters = new List<Util.DBParameter>();

            Monto.dbType = System.Data.DbType.Decimal;
            Monto.parameterName = "@Monto";
            Monto.value = rCompra.Monto;
            parameters.Add(Monto);

            IdBeneficiario.dbType = System.Data.DbType.Int32;
            IdBeneficiario.parameterName = "@IdBeneficiario";
            IdBeneficiario.value = rCompra.IdBeneficiario;
            parameters.Add(IdBeneficiario);

            IdPostnet.dbType = System.Data.DbType.Int32;
            IdPostnet.parameterName = "@IdPostnet";
            IdPostnet.value = rCompra.IdPostNet;
            parameters.Add(IdPostnet);

            IdTarjeta.dbType = System.Data.DbType.Int32;
            IdTarjeta.parameterName = "@IdTarjeta";
            IdTarjeta.value = rCompra.IdTarjeta;
            parameters.Add(IdTarjeta);



            SqlCommand miCommand = Util.SQLCommandBuild("CompraInsert", parameters);

            return decimal.Parse(miCommand.ExecuteScalar().ToString());
        }
    }
}
